<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/8/12
 * Time: 11:40
 */
namespace App\Repositories;

use App\Models\UserPassage;

class UserPassageRepository
{
    /**
     * 创建用户子商户
     * @param array $params
     * @return mixed
     */
    public function create(array $params)
    {
        return UserPassage::create($params);
    }

    /**
     * 根据id获取还款账单资料
     * @param $id
     * @return mixed
     */
    public function byId($id)
    {
        return UserPassage::find($id);
    }

    public function first($passageId, $userId)
    {
        return UserPassage::where([
            'passage_id' => $passageId,
            'user_id' => $userId
        ])->first();
    }

    public function getSubMerchantNo($passageId, $userId)
    {
        return UserPassage::where([
            'passage_id' => $passageId,
            'user_id' => $userId
        ])->value('sub_merchant_no');
    }
}